Skip to content

Fix priority.toComponent() returning undefined when prioritizeSeoTags is false#262

Merged
staylor merged 2 commits intov3.0.0from
copilot/sub-pr-260-again
Mar 3, 2026
Merged

Fix priority.toComponent() returning undefined when prioritizeSeoTags is false#262
staylor merged 2 commits intov3.0.0from
copilot/sub-pr-260-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

The default priorityMethods in mapStateOnServer had toComponent: () => {} — an empty function body that implicitly returns undefined, violating the HelmetDatum interface contract of toComponent(): React.ReactElement[].

Changes

  • src/server.ts: Change the default toComponent fallback to explicitly return an empty array, matching the HelmetDatum type:
// Before — returns undefined, violates HelmetDatum interface
let priorityMethods = {
  toComponent: () => {},
  toString: () => '',
};

// After — returns React.ReactElement[] as required
let priorityMethods = {
  toComponent: (): React.ReactElement[] => [],
  toString: () => '',
};

This ensures helmet.priority.toComponent() is always safe to call (e.g. spread into JSX) regardless of whether prioritizeSeoTags is enabled.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…oTags is false

Co-authored-by: staylor <52932+staylor@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on React 19 support and TypeScript cleanup Fix priority.toComponent() returning undefined when prioritizeSeoTags is false Mar 3, 2026
@staylor staylor marked this pull request as ready for review March 3, 2026 11:50
@staylor staylor merged commit b3ec04e into v3.0.0 Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants